﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Products_Category.aspx.cs" Inherits="Products_Category" %>
<%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxDataView" TagPrefix="dx" %>

<%@ Register assembly="DevExpress.Web.ASPxEditors.v10.2, Version=10.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v10.2, Version=10.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxRatingControl" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v10.2, Version=10.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxMenu" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v10.2, Version=10.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPopupControl" tagprefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div class="featured-post">
        <h2> 
            <asp:Label ID="lblCation" runat="server" Text=""></asp:Label></h2>
        
        <dx:ASPxDataView ID="ASPxDataView1" runat="server" 
            DataSourceID="SqlDataSourceProducts" 
            CssFilePath="~/App_Themes/Office2010Silver/{0}/styles.css" CssPostfix="Office2010Silver" 
            ItemSpacing="21px" PagerPanelSpacing="0px" 
            SpriteCssFilePath="~/App_Themes/Office2010Silver/{0}/sprite.css" 
            RowPerPage="2" Width="131px">
            <LoadingPanelStyle ImageSpacing="5px">
            </LoadingPanelStyle>
            <LoadingPanelImage Url="~/App_Themes/Office2010Silver/Web/Loading.gif">
            </LoadingPanelImage>
            <DisabledStyle ForeColor="#989898">
            </DisabledStyle>
            <ItemTemplate>
                <dx:ASPxImage ID="ASPxImage1" runat="server" Height="155px" 
                    ImageUrl='<%# Eval("Thumbnail") %>' Width="113px">
                </dx:ASPxImage>
                <br />
                <dx:ASPxHyperLink ID="ASPxHyperLink1" runat="server" 
                    NavigateUrl='<%# Eval("ProductID", "~/ProductDetail.aspx?id={0}") %>' 
                    Text='<%# Eval("ProductName") %>' />
                <br />
                
                <asp:Label CssClass="PriceLabel" ID="PriceLabel" runat="server" 
                    Text='<%#(float.Parse(Eval("SaleOff", "{0}")) == 0) ? Eval("Price", "<b>Giá bìa:</b>{0:N0}đ") : Eval("Price", "<strike><b>Giá bìa:</b>{0:N0}đ</strike>") %>' />
                <br />
                
                <asp:Label CssClass="SaleOffLabel" ID="SaleOffLabel" runat="server" 
                    Text='<%# Eval("SaleOff", "<b>Giảm:</b> {0:N0}đ") %>' 
                    Visible='<%# float.Parse(Eval("SaleOff", "{0}")) == 0 ? false : true %>' />
                <br />
                <asp:Label CssClass="NewPriceLabel" ID="NewPriceLabel" runat="server" 
                    Text='<%# String.Format("<b>Giá bán:</b> {0:N0}đ (Giảm {1:P})", float.Parse(Eval("Price").ToString()) - float.Parse(Eval("SaleOff").ToString()), float.Parse(Eval("SaleOff").ToString()) / float.Parse(Eval("Price").ToString()))%>' 
                    Visible='<%# float.Parse(Eval("SaleOff", "{0}")) == 0 ? false : true %>' />
                <asp:HiddenField ID="HiddenField1" runat="server" Value='<%# Eval("ProductID") %>' />
                <br />
                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <asp:Button CssClass="Button" ID="_btnShoppingCart" runat="server" CommandArgument='<%#Eval("ProductID") %>' onclick="_lnkAddToCart_Click"  Text="Thêm vào giỏ"
                        Visible='<%# int.Parse(Eval("Amount").ToString()) <= 0 ? false : true %>' />
                        
                        <dx:ASPxLabel ID="ASPxLabel1" runat="server" Text="Hết hàng" CssClass="MessageLabel" Visible='<%# int.Parse(Eval("Amount").ToString()) <= 0 ? true : false %>'>
                        </dx:ASPxLabel>
                        <asp:Timer ID="Timer1" Interval="5000" runat="server" ontick="Timer1_Tick" >
                        </asp:Timer>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
                    </Triggers>
                </asp:UpdatePanel>
            </ItemTemplate>
            <PagerSettings Position="Bottom">
            </PagerSettings>
        </dx:ASPxDataView>
    </div><!--End .#featured-post-->
    <asp:SqlDataSource ID="SqlDataSourceProductCate" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DB_BookStoreConnectionString %>" 
        
        
        SelectCommand="SELECT * FROM [Products] WHERE ([PublisherID] = @PublisherID)">
        <SelectParameters>
            <asp:QueryStringParameter Name="PublisherID" QueryStringField="id" 
                Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSourceProductsNew" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DB_BookStoreConnectionString %>" 
        
        SelectCommand="SELECT [ProductID], [ProductName], [Price], [SaleOff], [Thumbnail], [Amount] FROM [Products] ORDER BY [AddingDate] DESC">
    </asp:SqlDataSource>
    
    <asp:SqlDataSource ID="SqlDataSourceProductsSaleOff" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DB_BookStoreConnectionString %>" 
        
        SelectCommand="SELECT TOP(30) [ProductID], [ProductName], [Price], [SaleOff], [Thumbnail], [Amount] FROM [Products] WHERE [SaleOff] &gt; 0 ORDER BY NEWID()">
    </asp:SqlDataSource>
</asp:Content>

